
#include "gd32f30x_can.h"
#include "clean_can_msg.h"

STR_CLEAN_CTRL    cleanMsgCtrl;

STR_CLEAN_CANMSG  cleanMsgRec;


/*!
    \brief      
    \param[in]  none
    \param[out] none
    \retval     none
*/

void clean_rece_canmailbox_set(uint8_t fifo_num)
{
	
    can_filter_parameter_struct can_filter;
    can_struct_para_init(CAN_INIT_STRUCT, &can_filter);
	
	
	can_filter.filter_number      = 11;	
    can_filter.filter_mode        = CAN_FILTERMODE_LIST;
    can_filter.filter_bits        = CAN_FILTERBITS_32BIT;
	
    can_filter.filter_list_high   = ((ID_CAN_CLEAN_RUN_STATUS & 0xFFFFE000) >> 13);
    can_filter.filter_list_low    = (((ID_CAN_CLEAN_RUN_STATUS & 0x00001FFF) << 3) | (1 << 2));
	
    can_filter.filter_mask_high   = ((ID_CAN_CLEAN_OUTPUT_FSM & 0xFFFFE000) >> 13);
    can_filter.filter_mask_low    = (((ID_CAN_CLEAN_OUTPUT_FSM & 0x00001FFF) << 3) | (1 << 2));
	
    can_filter.filter_fifo_number = fifo_num;
    can_filter.filter_enable      = ENABLE;
    can_filter_init(&can_filter);


	
	can_filter.filter_number      = 10;	
    can_filter.filter_mode        = CAN_FILTERMODE_LIST;
    can_filter.filter_bits        = CAN_FILTERBITS_32BIT;
	
    can_filter.filter_list_high   = ((ID_CAN_CLEAN_FAULT_CODE & 0xFFFFE000) >> 13);
    can_filter.filter_list_low    = (((ID_CAN_CLEAN_FAULT_CODE & 0x00001FFF) << 3) | (1 << 2));
	
    can_filter.filter_mask_high   = ((ID_CAN_CLEAN_SYSTEM & 0xFFFFE000) >> 13);
    can_filter.filter_mask_low    = (((ID_CAN_CLEAN_SYSTEM & 0x00001FFF) << 3) | (1 << 2));
	
    can_filter.filter_fifo_number = fifo_num;
    can_filter.filter_enable      = ENABLE;
    can_filter_init(&can_filter);
	
	

	can_filter.filter_number      = 9;	
    can_filter.filter_mode        = CAN_FILTERMODE_LIST;
    can_filter.filter_bits        = CAN_FILTERBITS_32BIT;
	
    can_filter.filter_list_high   = ((ID_CAN_CLEAN_CURRENT_X1 & 0xFFFFE000) >> 13);
    can_filter.filter_list_low    = (((ID_CAN_CLEAN_CURRENT_X1 & 0x00001FFF) << 3) | (1 << 2));
	
    can_filter.filter_mask_high   = ((ID_CAN_CLEAN_CURRENT_X2 & 0xFFFFE000) >> 13);
    can_filter.filter_mask_low    = (((ID_CAN_CLEAN_CURRENT_X2 & 0x00001FFF) << 3) | (1 << 2));
	
    can_filter.filter_fifo_number = fifo_num;
    can_filter.filter_enable      = ENABLE;
    can_filter_init(&can_filter);

}



/*!
    \brief      
    \param[in]  none
    \param[out] none
    \retval     none
*/

void clean_ctrl_msg_store(STR_CAN_MESSAGE *can_msg)
{
	for(uint8_t i=0; i<8; i++)
	{
		can_msg->data[i] = cleanMsgCtrl.data[i];
	}
}










